package net.xdclass.onlinexdclass.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.xdclass.onlinexdclass.model.entity.Video;
import net.xdclass.onlinexdclass.model.entity.VideoBanner;
import net.xdclass.onlinexdclass.service.VideoService;
import net.xdclass.onlinexdclass.utils.JsonDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("视频接口")
@RestController
@RequestMapping("/api/v1/pub/video")
public class VideoController {


    @Autowired
    private VideoService videoService;


    @ApiOperation(value = "查询轮播图")
    @GetMapping("/list_banner")
    private JsonDate listBanner() {

        List<VideoBanner> videoBanners = videoService.listBanner();

        return JsonDate.bulidSuccess(videoBanners);
    }


    @ApiOperation(value = "数组显示视频列表")
    @GetMapping("/list")
    private JsonDate listVidoe() {

        return JsonDate.bulidSuccess(videoService.videoList());
    }


    @ApiOperation(value = "查询视频", notes = "根据ID查询视频")
    @ApiImplicitParam(name = "video_id", value = "视频id", required = true, dataType = "INT")
    @GetMapping("/video_id")
    private JsonDate findDateilById(@RequestParam(value = "video_id", required = true) Integer videoId) {
        if (null != videoId && 0 != videoId) {
            Video video = videoService.findDetailById(videoId);

            return JsonDate.bulidSuccess(video);
        }
        return JsonDate.bulidError("参数为空");

    }


}
